package com.learn.databinding.workwithobservabledataobjects.model

import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import com.learn.databinding.BR

class User2 : BaseObservable() {
    /**
     * [Bindable]，编译时会在BR文件中生成一个映射id的键值对。
     * 目前看就是为了方便在调用notifyPropertyChanged()时获取属性id的
     */
    @get:Bindable
    var firstName: String = ""
        set(value) {
            field = value
            // 属性变化时通知监听者
            notifyPropertyChanged(BR.firstName)
        }

    @get:Bindable
    var lastName: String = ""
        set(value) {
            field = value
            notifyPropertyChanged(BR.lastName)
        }
}